#pragma once
#include <windows.h>

void RegisterWinClass(LPCSTR lpszClassName, WNDPROC WndProc)
{
    WNDCLASS wc;
    wc.lpszClassName = lpszClassName;
    wc.lpfnWndProc = WndProc;
    wc.style = CS_OWNDC | CS_VREDRAW | CS_HREDRAW;
    wc.hInstance = NULL;
    wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
    wc.hCursor = LoadCursor(NULL, IDC_ARROW);
    wc.hbrBackground = (HBRUSH)(GetStockObject(BLACK_BRUSH));
    wc.lpszMenuName = TEXT("SP");
    wc.cbClsExtra = 0;
    wc.cbWndExtra = 0;
    RegisterClass(&wc);
}

bool OnlyOneRunning() {
    HANDLE hMutex;
    hMutex = CreateMutex(NULL, FALSE, TEXT("RunOnlyOneInstance"));
    if (hMutex == NULL || ERROR_ALREADY_EXISTS == ::GetLastError())
    {
        MessageBox(NULL, TEXT("The program is already running!"), TEXT("Notice"), MB_OK);

        return false;
    }
    else return true;

}
